/*
* Display an error from the serial subsystem.
*/
-void GPS_Serial_Error(char *hdr)
+void GPS_Serial_Error(char *mb, ...)
{
+ va_list ap;
char msg[200];
char *s;
+ int b;
- strcpy(msg, hdr);
- s = msg + strlen(hdr);
+ va_start(ap, mb);
+// strcpy(msg, msg);
+ b = vsnprintf(msg, sizeof(msg), mb, ap);
+ s = msg + b;
*s++ = ':';
*s++ = ' ';
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0,
- GetLastError(), 0, s, sizeof(msg) - strlen(hdr) - 2, 0 );
+ GetLastError(), 0, s, sizeof(msg) - b - 2, 0 );
GPS_Error(msg);
}
OPEN_EXISTING, 0, NULL);
if (comport == INVALID_HANDLE_VALUE) {
- GPS_Serial_Error("CreateFile");
+ GPS_Serial_Error("CreateFile on '%s' failed", port);
gps_errno = SERIAL_ERROR;
return 0;
}
tio.StopBits = ONESTOPBIT;
if (!SetCommState (comport, &tio)) {
- GPS_Serial_Error("SetCommState");
+ GPS_Serial_Error("SetCommState on port '%s' failed", port);
CloseHandle(comport);
comport = INVALID_HANDLE_VALUE;
gps_errno = SERIAL_ERROR;
{
perror("open");
gps_errno = SERIAL_ERROR;
- GPS_Error("SERIAL: Cannot open serial port");
+ GPS_Error("SERIAL: Cannot open serial port '%s'", port);
return 0;
}
{
perror("open");
gps_errno = HARDWARE_ERROR;
- GPS_Error("SERIAL: Cannot open serial port");
+ GPS_Error("SERIAL: Cannot open serial port '%s'", port);
return 0;
}
if((*fd = open(port, O_RDWR))==-1)
{
perror("open");
- GPS_Error("SERIAL: Cannot open serial port");
+ GPS_Error("SERIAL: Cannot open serial port '%s'", port);
gps_errno = SERIAL_ERROR;
return 0;
}
}
if(!GPS_Serial_Savetty(port))
{
- GPS_Error("Cannot access serial port");
+ GPS_Error("Cannot access serial port '%s'", port);
gps_errno = SERIAL_ERROR;
return 0;
}
if(!GPS_Serial_Open(fd,port))
{
- GPS_Error("Cannot open serial port");
+ GPS_Error("Cannot open serial port '%s'", port);
gps_errno = SERIAL_ERROR;
return 0;
}
if(!GPS_Serial_Savetty(port))
{
- GPS_Error("Cannot access serial port");
+ GPS_Error("Cannot access serial port '%s'", port);
gps_errno = SERIAL_ERROR;
return 0;
}
if(!GPS_Serial_Open_NMEA(fd,port))
{
- GPS_Error("Cannot open serial port");
+ GPS_Error("Cannot open serial port '%s'", port);
gps_errno = SERIAL_ERROR;
return 0;
}
if (hdevinfo == INVALID_HANDLE_VALUE) {
GPS_Serial_Error("SetupDiGetClassDevs failed");
+ warning("Is the Garmin driver installed?");
return 0;
}
usb_handle = CreateFile(pdd->DevicePath, GENERIC_READ|GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL );
if (usb_handle == INVALID_HANDLE_VALUE) {
- GPS_Serial_Error("CreateFile failed");
+ GPS_Serial_Error("CreateFile on '%' failed", pdd->DevicePath);
return 0;
}